//
//  KLMainDataModel.m
//  Koala
//
//  Created by cao pan on 11/22/14.
//  Copyright (c) 2014 Anonymous. All rights reserved.
//

#import "KLMainDataModel.h"
#import "EXRequestClient.h"
#import "EXRequestConfig.h"

@implementation KLMainDataModel

+ (void)getMainDataList:(void (^) (NSArray * dataArr))callback
{
    [[EXRequestClient sharedClient] requestWithUri:/*API_DOUBAN_IMAGE*/ API_TENNEWS
                                     responseBlock:^(EXResponseMessage *responseMessage) {
                                         NSMutableArray * muatableArr = [[NSMutableArray alloc] init];
                                         NSArray * arr = responseMessage.collectionArr;
                                         for (int i = 0 ; i < arr.count ; i++) {
                                             KLMainDataModel * mainDataModel = [[KLMainDataModel alloc] init];
                                             NSDictionary * dict = [arr objectAtIndex:i];
                                             
                                             NSLog(@"dict %@",dict);
                                             
                                             NSDictionary * dict1 = [dict objectForKey:@"property1"];
                                             mainDataModel.titleStr = [dict1 objectForKey:@"text"];
                                             mainDataModel.hrefStr = [dict1 objectForKey:@"href"];
                                             
                                             NSDictionary * dict2 = [dict objectForKey:@"property2"];
                                             mainDataModel.imageUrl = [dict2 objectForKey:@"src"];
//                                             mainDataModel.titleStr = [dict objectForKey:@"property2"];
//                                             
//                                             NSDictionary * propertyDict = [dict objectForKey:@"property1"];
//                                             mainDataModel.imageUrl = [propertyDict objectForKey:@"src"];
//                                             mainDataModel.hrefStr  = [propertyDict objectForKey:@"href"];
                                             
                                             [muatableArr addObject:mainDataModel];
                                         }
                                         callback(muatableArr);
                                     }];
}



+ (NSArray *)testArrData
{
    NSMutableArray * testArray = [[NSMutableArray alloc] init ];
    KLMainDataModel * mainModel = [[KLMainDataModel alloc] init];
    mainModel.titleStr = @"美国天后级歌手再次携手❤️专辑席全球";
    mainModel.detailStr = @"排行榜第一名";
    [testArray addObject:mainModel];
    return testArray;
}


@end
